define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'party/partygoods/index' + location.search,
                    add_url: 'party/partygoods/add',
                    edit_url: 'party/partygoods/edit',
                    del_url: 'party/partygoods/del',
                    multi_url: 'party/partygoods/multi',
                    import_url: 'party/partygoods/import',
                    table: 'qsy_party',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'shop.shopname', title: __('Shop.shopname'), operate: 'LIKE'},
                        {field: 'big_type', title: __('Big_type'),searchList:pidList,formatter: Table.api.formatter.status,},
                        {field: 'type.name', title: __('Small_type'), operate: 'LIKE'},
                        // {field: 'type.name', title: __('Type.name'), operate: 'LIKE'},
                        // {field: 'shop_id', title: __('Shop_id')},
                        // {field: 'big_type', title: __('Big_type')},
                        {field: 'title', title: __('Title'), operate: 'LIKE'},
                        // {field: 'small_type', title: __('Small_type')},
                        {field: 'cover_img', title: __('Cover_img'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
                        {field: 'label', title: __('Label'), operate: 'LIKE'},
                        // {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        // {field: 'price', title: __('Price'), operate:'BETWEEN'},
                        {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
                        {field: 'sold_num', title: __('Sold_num')},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        // {field: 'del_time', title: __('Del_time'), operate:'RANGE', addclass:'datetimerange', formatter:Table.api.formatter.datetime},

                        {
                            field: "operate",
                            title: __("Operate"),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [ {
                                name: "detail",
                                title: __("详情"),
                                classname: "btn btn-xs btn-info btn-dialog",
                                icon: "fa fa-eye",
                                url: "party/partygoods/detail"
                            }],
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
